﻿<?php
	$db = mysql_connect("mysql513.in.shared-server.net:16033", "JRtu434", "qvoiceDB1");
	mysql_select_db("JRtu434", $db);
	$sql = "insert into tbl_url (rid,url) values (\"";
	if( isset($_POST["urls"]) && isset($_POST["rid"]) )
	{
	$target = preg_split("/(\r\n|\n|\r)/",$_POST["urls"]);
	//put each URL in the database
	foreach($target as &$val){
		if (!(empty($val))){
			mysql_query($sql.$_POST["rid"]."\",\"".$val."\")");
			$update = true;
		}
	}
	unset($val);
	
	mysql_close();
	}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Multi URL Uploader</title>
	<?php include 'layout.php'; ?> 
	</head>
	<body>
		<div id="content"><center>Multiple URL Uploader</center>
			<form action="multiurl.php" method="post">
				<table>
					<tr>
						<th>RID</th>
						<th>Multiple URLs<th>
					</tr>
					<tr>
						<td valign="top"><input type="text" size="30" maxlength="60" name="rid" placeholder="Input RID here"></td>
						<td><textarea name="urls" rows="20" cols="20"></textarea></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><input type="submit" value="submit" name="submit"></td>
					</tr>
			</table><?php if (isset($update) && $update) echo "URLs input success!"?>
		</form>
		</div>
		</body>
</html>
